package com.lixl.collection;

import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;

public class SetDemo {

	public static void main(String[] args) {

		hashSetTest();
		
		treeSetTest();
		
		
	}
	
	public static void hashSetTest(){
		HashSet<String> set = new HashSet<String>();
		set.add("s3");
		set.add("s1");
		set.add("s2");
		set.add("s1");
		print(set);
	}
	
	public static void treeSetTest(){
		TreeSet<String> set = new TreeSet<String>();
		set.add("s3");
		set.add("s1");
		set.add("s2");
		set.add("s1");
		print(set);
	}
	
	private static void print(Set<String> set ){
		for(String s:set){
			System.out.print(s+",");
		}
		System.out.println();
	}

}
